<template>
	<view>
		<uni-nav-bar left-icon="back" @click-left="back" @click-right="save()" right-text="保存" title="邮箱绑定"></uni-nav-bar>
		<view class="list">
			<view class="list-item">
				<text>邮箱地址</text>
				<view class="input">
					<input class="inputText" type="text" data-name="email" @input="input" :value="email" placeholder="请输入您的邮箱地址" placeholder-class="placeholder" />
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue';
import uniIcons from '@/components/uni-icons/uni-icons.vue';
export default {
	components: { uniNavBar, uniIcons },
	data() {
		return {
			email: ''
		};
	},
	methods: {
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		input(e) {
			let name = e.target.dataset.name;
			let value = e.detail.value;
			this[name] = value;
		},
		async save() {
			if (!this.email) {
				uni.showToast({
					title: '请输入邮箱号',
					duration: 2000
				});
				return false;
			}
			let res = await this.$request.post('/setting/editMemberInfo', {
				data: {
					email: this.email
				}
			});
			if (res.data.code == 10000) {
				uni.showToast({
					title: '保存成功',
					duration: 2000
				});
			} else {
				uni.showToast({
					title: '保存失败',
					duration: 2000
				});
			}
		}
	}
};
</script>

<style lang="scss">
.list {
	width: 100%;
	box-sizing: border-box;
	padding-left: 30upx;
	.list-item {
		width: 100%;
		height: 110upx;
		border-bottom: 2upx solid #e7e7e7;
		display: flex;
		align-items: center;
		justify-content: space-between;
		box-sizing: border-box;
		padding-right: 20upx;
		font-size: $uni-font-size-base;
		color: #333333;
		.input {
			width: 500upx;
			height: 100%;
			display: flex;
			align-items: center;
			justify-content: center;
			.inputText {
				color: #333333;
				font-size: $uni-font-size-base;
				width: 100%;
				text-align: right;
				box-sizing: border-box;
			}
		}
	}
}
.placeholder {
	color: #d7d7d7;
}
</style>
